#include "DoorElement.hpp"

DoorElement::DoorElement(float x, float y, float wallDirection, b2World* world) : ActionableElement(true) {
    this->wallDirection = wallDirection;

    b2BodyDef bodyDefinition;
    bodyDefinition.userData = this;
    bodyDefinition.position.Set(x, y);

    b2EdgeShape shape;
    shape.Set(b2Vec2(0.0f, 1.0f), b2Vec2(0.0f, -1.0f));

    this->body = world->CreateBody(&bodyDefinition);
    this->body->CreateFixture(&shape, 0.0f);
}

bool DoorElement::isDoor() {
    return true;
}

void DoorElement::turnOff() {
    this->body->SetActive(false);
}

void DoorElement::turnOn() {
    this->body->SetActive(true);
}
